// 域名
var domain = 'www.daylaiyy.com'

// 拼接域名
const newUrl = 'https://' + domain;

// var cflz_service_url = "https://m.dyl.yuneyuan.com/netcflz_wx/service/app_data_action.ashx";						//大医莱
// var appUrl = "https://dyl.yuneyuan.com/";						//大医莱
// var cflzUrl = "https://m.dyl.yuneyuan.com/";

// var cflz_service_url = "https://th.yixianmedical.com/netcflz_wx/service/app_data_action.ashx";
// var appUrl = "https://th.yixianmedical.com/";
// var cflzUrl = "http://app.yixianmedical.com/";
// var appOrgId = "44000002";						//同和

// var cflz_service_url = "https://lj.nxk520.com/netcflz_wx/service/app_data_action.ashx";
// var appUrl = "https://lj.nxk520.com/";
// var cflzUrl = "http://lj.nxk520.com/";
// var appOrgId = "440004902";						//廉江

// var cflz_service_url = "https://zz.nxk520.com/netcflz_wx/service/app_data_action.ashx";
// var cflzUrl = "https://hospital-test.yixianmedical.com";
// var appUrl = "https://hospital-test.yixianmedical.com";
// var appOrgId = "440004904";							//第二

// 是否测试服
const TESTING = /test\.yixianmedical/.test(newUrl)

//是否是His配置
const isHis = /lianjiang/.test(newUrl)

// 能否使用医保
const hasYiBao = /(lianjiang|zhuhai)/.test(newUrl)

// 是否暖禾
const isNuanHe = /nuanhehealth/.test(newUrl)

// 是否需要自主开单
const isFreeBilling = /chengshi/.test(newUrl) || /test\.yixianmedical/.test(newUrl)

// 是否成都大医睐
const isChengDu = /daylaiyy/.test(newUrl) || TESTING

// 使用的视频商家 Tencent / agora
const TRTCTYPE = 'agora'

function switchStateKey(inside) {
	if (isHis && inside) {
		// his订单状态
		STcancel = -1 //-1:已取消
		STwaitPay = 0 // 0:待支付
		STwaitSend = 1 // 1:已支付(待发货)
		STwaitTake = 2 // 2:待自提
		STfinished = 3 // 3:已结束（已完成）
	} else {
		// 非his订单状态
		STcancel = 0, // 0:已取消
			STwaitPay = 10, //10:未付款(待付款)
			STwaitSend = 20, //20:待发货
			STsended = 30, //30:已发货(待收货)
			STwaitTake = 35, //35:待自提
			STfinished = 40 //40:已收货(已完成)
	}
}
switchStateKey(false)

// 获取appid
function getAPPID(){
  // 测试服
  if(TESTING){
    return 'wx338970a4406730d3'
  }
  // 不同医院的APPID在这里修改
  return 'wx338970a4406730d3'
}

var jsonUser, jsonDoc, jsonShop;
//用户编码,用户类型,问诊类型,医生编码
var user_id, user_type, hospital_id, log_type, doctor_id;
//用户姓名,医生姓名
var userName, doctorName;

// 图片路径处理
function getUserImgPub(user_img, srcimg) {
	if (isUndefinedAndEmpty(user_img)) {
		if (isUndefinedAndEmpty(srcimg)) {
			user_img = '/static/images/head.png';
		} else {
			user_img = srcimg;
		}

	} else if (user_img.indexOf('http') == -1) { //微信头像
		user_img = appUrl + user_img;
	}
	return user_img;
}

function strToJson(jsonStr) {
	return eval('(' + jsonStr + ')');
}

function jsonToStr(jsonObj) {
	return JSON.stringify(jsonObj);
}

/*将用户数据存储到LocalStorage中*/
function setUserInfo(userJson) {
	var user_type = userJson.type;
	localStorage.setItem("user_type", user_type); //用户类型
	if (user_type == 'P') {
		sessionStorage.setItem("user_id", userJson.id); //用户编码
		localStorage.setItem("user_name", userJson.mobile); //登录账号
	} else if (user_type == 'S') {
		sessionStorage.setItem("user_id", userJson.id); //用户编码
		localStorage.setItem("user_name", userJson.mobile); //登录账号
	}
	sessionStorage.setItem("DSXBuserJson", jsonToStr(userJson));
	localStorage.setItem("DSXBuserJson", jsonToStr(userJson));
}

/*从cookie中得到一条userjson 数据*/
function getUserInfo() {
	// var userJson = sessionStorage.getItem('DSXBuserJson');
	var userJson = localStorage.getItem('DSXBuserJson');
	if (isUndefinedAndEmpty(userJson)) {
		return {};
	}
	return strToJson(userJson);
}

function getUserId() {
	// return sessionStorage.getItem('user_id');
	return localStorage.getItem('user_id');
}

/*存入缓存 用户 //存入缓存 服务点 登录类型 1 用户 2服务点*/
function setUserType(index) {
	sessionStorage.setItem("user_type", index);
}

/*获取用户登录类型缓存 登录类型 0 用户 1医生*/
function getUserType() {
	var num = sessionStorage.getItem("user_type");
	return num;
}

function isUndefinedAndEmpty(obj) {
	obj = $.trim(obj);
	if (undefined == obj || "undefined" == obj || "" == obj || null == obj) {
		return true;
	}
	return false;
}

/*判断当前用户是否已经登录*/
function isLogin() {
	strUserId = getUserId();
	// user_type = localStorage.getItem("user_type");
	bResult = !isUndefinedAndEmpty(strUserId);
	if (bResult)
		user_id = parseInt(strUserId);
	return bResult;
}

function checkLogin() {
	if (!isLogin()) {
		goPage('login.htm');
	}
}

/*获取当前日期*/
function getCurrDate() {
	var myDate = new Date;
	var year = myDate.getFullYear(); //年
	var month = myDate.getMonth() + 1 < 10 ? "0" + (myDate.getMonth() + 1) : (myDate.getMonth() + 1); //月
	var day = myDate.getDate() < 10 ? "0" + myDate.getDate() : myDate.getDate(); //日
	return year + '-' + month + '-' + day;
}

//请求数据,strMsgTag数据名称，pJson，callBack
function GetPageData(strMsgTag, pJson, callBack) {
	$.showLoading();
	var dataJson = {
		"rand": Math.random()
	};
	if (!isSpace(pJson)) {
		for (var key in pJson) {
			dataJson[key] = pJson[key];
		}
	}
	var ajaxArgs = {
		url: cflz_service_url,
		data: dataJson,
		succCallback: callBack,
		type: "post",
		errorCallback: function(errorMsg) {
			msgInfo("程序错误，" + errorMsg);
		}
	};
	$ajax(ajaxArgs);
}

function ajaxPost(url, pJson, callBack) {
	ajaxDo('post', 'json', url, pJson, callBack);
}

function ajaxPostH(url, pJson, callBack) {
	ajaxDo('post', 'html', url, pJson, callBack);
}

function ajaxGet(url, pJson, callBack) {
	ajaxDo('get', 'json', url, pJson, callBack);
}

function ajaxGetH(url, pJson, callBack) {
	ajaxDo('get', 'html', url, pJson, callBack);
}

function ajaxDo(doType, dataType, url, pJson, callBack) {
	var dataJson = {
		"orgid": appOrgId,
		"rand": Math.random()
	};
	if (!isSpace(pJson)) {
		for (var key in pJson) {
			dataJson[key] = pJson[key];
		}
	}
	var strAjaxUrl, ajaxJson;
	if ((url.charAt(0) == '/' && url.indexOf('.ashx') > -1) || url.indexOf('http:') > -1) {
		strAjaxUrl = cflzUrl + url;
		ajaxJson = dataJson;
		// console.log(strAjaxUrl,ajaxJson)
	} else {
		//todo
		// if(url == 'publicLogin_login_loginData'){
		// 	dataJson = {};
		// }else{
		dataJson = {
			"rand": Math.random()
		};
		// }
		if (!isSpace(pJson)) {
			for (var key in pJson) {
				dataJson[key] = pJson[key];
			}
		}
		//

		strAjaxUrl = appUrl + url + '.do';
		ajaxJson = {
			"mapStr": jsonToStr(dataJson)
		};
	}
	var ajaxArgs = {
		url: strAjaxUrl,
		data: ajaxJson,
		succCallback: callBack,
		dataType: dataType || "json",
		type: doType || "post",
		errorCallback: function(errorMsg) {
			msgInfo("系统异常，错误为" + errorMsg);
		}
	};
	$ajax(ajaxArgs);
}

//ajax函数二次封装
function $ajax(ajaxArgs) {
	var bAsync = ajaxArgs.async || false; //异步请求
	var strDataType = ajaxArgs.dataType || 'json'; //接收数据类型
	var strType = ajaxArgs.type || 'get'; //请求类型
	var bLoad = ajaxArgs.isLoad || false; //是否显示loading动画
	var bLoadParent = ajaxArgs.isParent || false; //显示父页loading动画
	var strLoadText = ajaxArgs.loadText || ''; //显示内容
	var succCallback = ajaxArgs.succCallback; //成功回调函数
	var errorCallback = ajaxArgs.errorCallback; //失败回调函数
	$.ajax({
		async: bAsync,
		url: ajaxArgs.url,
		data: ajaxArgs.data,
		dataType: strDataType,
		type: strType,
		success: function(rstData) {
			$.hideLoading();
			if ($.isFunction(succCallback))
				succCallback(rstData);
		},
		error: function(XMLHttpRequest, textStatus, errorThrown) {
			$.hideLoading();
			if ($.isFunction(errorCallback))
				errorCallback(textStatus + "\r\n" + errorThrown);
		},
		complete: function() { //结束loading
			if (bLoad) {}
		}
	});
}

function newAjaxPost(url, pJson, callBack) {
	newAjaxDo('post', 'json', url, pJson, callBack);
}

function newAjaxDo(doType, dataType, url, pJson, callBack) {
	var dataJson = {};
	if (!isSpace(pJson)) {
		for (var key in pJson) {
			dataJson[key] = pJson[key];
		}
	}
	var strAjaxUrl, ajaxJson;
	strAjaxUrl = newUrl + url;
	ajaxJson = JSON.stringify(dataJson);
	var ajaxArgs = {
		url: strAjaxUrl,
		data: ajaxJson,
		succCallback: callBack,
		dataType: dataType || "json",
		type: doType || "post",
		errorCallback: function(errorMsg) {
			msgInfo("系统异常，错误为" + errorMsg);
		}
	};
	$newAjax(ajaxArgs);
}
//ajax函数二次封装
function $newAjax(ajaxArgs) {
	var token = null;
	var userJson = localStorage.getItem('DSXBuserJson');
	if (userJson) {
		token = strToJson(userJson).h5Token
	}
	var bAsync = ajaxArgs.async || false; //异步请求
	var strDataType = ajaxArgs.dataType || 'json'; //接收数据类型
	var strType = ajaxArgs.type || 'get'; //请求类型
	var bLoad = ajaxArgs.isLoad || false; //是否显示loading动画
	var bLoadParent = ajaxArgs.isParent || false; //显示父页loading动画
	var strLoadText = ajaxArgs.loadText || ''; //显示内容
	var succCallback = ajaxArgs.succCallback; //成功回调函数
	var errorCallback = ajaxArgs.errorCallback; //失败回调函数
	$.ajax({
		async: bAsync,
		url: ajaxArgs.url,
		data: ajaxArgs.data,
		dataType: strDataType,
		type: strType,
		beforeSend: function(request) { //开始loading
			if (token) {
				request.setRequestHeader("h5Token", token);
			}
		},
		contentType: 'application/json',
		success: function(rstData) {
			$.hideLoading();
			if (rstData.code == '2001') {
				sessionStorage.clear();
				localStorage.clear();
				if (/inquiry_doctor_index/.test(window.location.href) || /inquiry_user_personal/.test(window
						.location.href)) {

				} else {
					msgInfo(rstData.msg + ",即将回到首页", 1500);
					setTimeout(function() {
						outOfIFrame("inquiry_doctor_index.htm");
					}, 1500);
				}

				return
			} else if ($.isFunction(succCallback))
				succCallback(rstData);
		},
		error: function(XMLHttpRequest, textStatus, errorThrown) {
			$.hideLoading();
			if ($.isFunction(errorCallback))
				errorCallback(textStatus + "\r\n" + errorThrown);
		},
		complete: function() { //结束loading
			if (bLoad) {}
		}
	});
}

//判断字符串为空
function isSpace(strMain) {
	var strComp = strMain;
	try {
		if (strComp == "　" || strComp == "" || strComp == " " || strComp == null || strComp == "null" || strComp ==
			"0" || strComp.length == 0 || typeof strMain == "undefined" || strMain == "undefined") {
			return true;
		} else {
			return false;
		}
	} catch (e) {
		return false;
	}
}

//后退或前进
function goPageNo(count) {
	history.go(count);
}

// 跳出iframe标签
function outOfIFrame(url) {
	top.location.href = url;
}

//页面跳转
function goPage(url) {
	location.href = url;
}

// 跳出iframe标签
function outOfIFrame(url) {
	top.location.href = url;
}

//获取URL参数
function getQst(name) {
	var result = window.location.search.match(new RegExp("[\?\&]" + name + "=([^\&]+)", "i"));
	if (result == null || result.length < 1) {
		return "";
	}
	return decodeURI(result[1]);
}

//过滤HTML标签
function filterHTMLTag(str) {
	var msg = str.replace(/<\/?[^>]*>/g, ''); //去除HTML Tag
	msg = msg.replace(/[|]*\n/, ''); //去除行尾空格
	msg = msg.replace(/&nbsp;/ig, ''); //去掉npsp
	return msg;
}

//弹窗
function msgInfo(msg, time = 2000) {
	if (msg == "") msg = "建设中……";
	$.toast.prototype.defaults.duration = time; //1秒
	$.toast(msg, 'text');
}
/**
 * 生成二维码
 * @param {any} obj
 * @param {any} width
 * @param {any} height
 */
function getQCCode(ID, obj, width, height) {
	var qrcode = new QRCode(document.getElementById(ID), {
		width: width,
		height: height
	});
	var elText = obj;
	if (!elText.value) {
		elText.focus();
		return;
	}
	qrcode.makeCode(elText.value);
}

function IsPhone(phones) {
	var myreg = /^[1][3,4,5,7,8,9][0-9]{9}$/;
	return (myreg.test(phones));
}


///验证身份证
function IsIdCard(idcard) {
	//var Errors = new Array("验证通过!", "身份证号码位数不对!", "身份证号码出生日期超出范围或含有非法字符!", "身份证号码校验错误!", "身份证地区非法!");
	var area = {
		11: "北京",
		12: "天津",
		13: "河北",
		14: "山西",
		15: "内蒙古",
		21: "辽宁",
		22: "吉林",
		23: "黑龙江",
		31: "上海",
		32: "江苏",
		33: "浙江",
		34: "安徽",
		35: "福建",
		36: "江西",
		37: "山东",
		41: "河南",
		42: "湖北",
		43: "湖南",
		44: "广东",
		45: "广西",
		46: "海南",
		50: "重庆",
		51: "四川",
		52: "贵州",
		53: "云南",
		54: "西藏",
		61: "陕西",
		62: "甘肃",
		63: "青海",
		64: "宁夏",
		65: "新疆",
		71: "台湾",
		81: "香港",
		82: "澳门",
		91: "国外"
	}
	idcard = idcard.toUpperCase();
	var Y, JYM;
	var S, M;
	var idcard_array = new Array();
	idcard_array = idcard.split("");
	//地区检验
	if (area[parseInt(idcard.substr(0, 2))] == null) {
		return false;
	}
	//身份号码位数及格式检验
	switch (idcard.length) {
		case 15:
			if ((parseInt(idcard.substr(6, 2)) + 1900) % 4 == 0 || ((parseInt(idcard.substr(6, 2)) + 1900) % 100 == 0 &&
					(parseInt(idcard.substr(6, 2)) + 1900) % 4 == 0))
				ereg =
				/^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$/; //测试出生日期的合法性
			else ereg =
				/^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$/; //测试出生日期的合法性
			if (ereg.test(idcard)) break;
			else {
				return false;
			}
			break;
		case 18:
			//18位身份号码检测
			//出生日期的合法性检查
			//闰年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))
			//平年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))
			if (parseInt(idcard.substr(6, 4)) % 4 == 0 || (parseInt(idcard.substr(6, 4)) % 100 == 0 && parseInt(idcard
					.substr(6, 4)) % 4 == 0))
				ereg =
				/^[1-9][0-9]{5}(19|20)[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}[0-9Xx]$/; //闰年出生日期的合法性正则表达式
			else ereg =
				/^[1-9][0-9]{5}(19|20)[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}[0-9Xx]$/; //平年出生日期的合法性正则表达式
			if (ereg.test(idcard)) { //测试出生日期的合法性
				//计算校验位
				S = (parseInt(idcard_array[0]) + parseInt(idcard_array[10])) * 7 +
					(parseInt(idcard_array[1]) + parseInt(idcard_array[11])) * 9 +
					(parseInt(idcard_array[2]) + parseInt(idcard_array[12])) * 10 +
					(parseInt(idcard_array[3]) + parseInt(idcard_array[13])) * 5 +
					(parseInt(idcard_array[4]) + parseInt(idcard_array[14])) * 8 +
					(parseInt(idcard_array[5]) + parseInt(idcard_array[15])) * 4 +
					(parseInt(idcard_array[6]) + parseInt(idcard_array[16])) * 2 +
					parseInt(idcard_array[7]) * 1 + parseInt(idcard_array[8]) * 6 +
					parseInt(idcard_array[9]) * 3;
				Y = S % 11;
				M = "F";
				JYM = "10X98765432";
				M = JYM.substr(Y, 1); //判断校验位
				if (M == idcard_array[17]) break; //检测ID的校验位
				else {
					return false;
				}
			} else {
				return false;
			}
			break;
		default:
			return false;
			break;
	}
	return true;
}


//判断一个变量是否是日期型
function isDate(sDate) {
	var arrDate = sDate.split("-");
	if (arrDate.length != 3) return false;

	var year = arrDate[0];
	var month = arrDate[1];
	var day = arrDate[2];

	if (isEmpty(year) || isEmpty(month) || isEmpty(day)) return false;
	if (isNaN(year) || isNaN(month) || isNaN(day)) return false;

	year = parseInt(LTrimZero(year));
	month = parseInt(LTrimZero(month));
	day = parseInt(LTrimZero(day));

	if (year < 0 || month > 12 || day > 31 || month <= 0 || day <= 0) return false;

	switch (month) {
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			return true;
		case 4:
		case 6:
		case 9:
		case 11:
			if (day > 30) return false;
			return true;
		case 2:

			//闰年
			if (0 == year % 4 && (year % 100) != 0 || 0 == year % 400) {
				if (day > 29) return false;
				return true;
			}
			//非闰年
			if (day > 28) return false;
			return true;
		default:
			return false;
	}
}


//判断一个字符串是否为空字符串
function isEmpty(s) {
	return "" == Trim(s);
}



/*=============== 数据处理函数 ===========*/
function LTrim(s) {
	for (var i = 0; i < s.length; i++) {
		if (s.charAt(i) != " ") {
			return s.substr(i, s.length - i);
		}
	}
	return "";
}

function RTrim(s) {
	for (var i = s.length - 1; i >= 0; i--) {
		if (s.charAt(i) != " ") {
			return s.substr(0, i + 1);
		}
	}
	return "";
}

function Trim(s) {
	if (typeof s == "undefined" || s == "undefined")
		s = "";
	else
		s = RTrim(LTrim(s));
	return s;
}


function LTrimZero(s) {
	for (var i = 0; i < s.length; i++) {
		if (s.charAt(i) != "0") {
			return s.substr(i, s.length - i);
		}
	}
	return "";
}

//验证证件号 并把生日, 性别赋值
function checkidno(idno, objbirth, objsex) {
	var nian, yue, ri, csrq, xingbie, s;
	var sex_code, birthdate;
	var s = idno.value;
	if (!IsIdCard(s)) {
		msgInfo("请输入正确的身份证号码！");
		return false;
	}
	//身份证为15位
	if (s.length == 15) {
		nian = s.substr(6, 2);
		yue = s.substr(8, 2);
		ri = s.substr(10, 2);
		csrq = "19" + nian + "-" + yue + "-" + ri;
		xingbie = s.charAt(14);
		if (xingbie % 2 == 0) {
			sex_code = "1";
		} else {
			sex_code = "0";
		}
		setCtlVal(objsex, sex_code);
		if (isDate(csrq)) {
			birthdate = csrq;
			setCtlVal(objbirth, csrq);
		} else {
			msgInfo("请输入正确的身份证号码！");
			return false;
		}
	}
	//身份证为18位
	else if (s.length == 18) {
		nian = s.substr(6, 4);
		yue = s.substr(10, 2);
		ri = s.substr(12, 2);
		csrq = nian + "-" + yue + "-" + ri;
		xingbie = s.charAt(16);
		if (xingbie % 2 == 0) {
			sex_code = "1";
		} else {
			sex_code = "0";
		}
		setCtlVal(objsex, sex_code);
		if (isDate(csrq)) {
			birthdate = csrq;
			setCtlVal(objbirth, csrq);
		} else {
			msgInfo("请输入正确的身份证号码！");
			return false;
		}
	} else {
		msgInfo("身份证号必需要15位或18位！");
		return false;
	}
	return true;
}

function setCtlVal(ctlId, ctlVal) {
	if (ctlId != null)
		ctlId.value = ctlVal;
}

function BindSelectData(ctrlId, tbName) {
	var str_item = "";
	GetPageData('获取字典', {
		"actName": "Doctor",
		"actTag": "D999",
		"tbName": tbName
	}, function(rstData) {
		$("#text_" + ctrlId).select({
			title: "",
			items: rstData,
			onChange: function(d) {
				$("#hid_" + ctrlId).val($("#text_" + ctrlId).attr("data-values"));
				console.log(this, d);
			},
			onClose: function() {
				console.log("close");
			},
			onOpen: function() {
				console.log("open");
			}
		});
	});
}

function SetFormCtls(rstData) {
	var str_name, str_key;
	$("input").each(function() {
		str_name = $(this).attr('id');
		if (!isSpace(str_name) && ((str_name.indexOf("hid_") == 0) || (str_name.indexOf("txt_") == 0) || (
				str_name.indexOf("ckb_") == 0))) {
			str_key = str_name.substring(4);
			if (str_key in rstData)
				$('#' + str_name).attr('value', rstData[str_key]);
		}
		if (!isSpace(str_name) && (str_name.indexOf("ckb_") == 0)) {
			str_key = str_name.substring(4);
			if (str_key in rstData && rstData[str_key] == '1')
				$('#' + str_name).attr('checked', true);
		}
	});
	$("select").each(function() {
		str_name = $(this).attr('id');
		if (!isSpace(str_name) && str_name.indexOf("ddl_") == 0) {
			str_key = str_name.substring(4);
			if (str_key in rstData)
				$('#' + str_name).attr('value', rstData[str_key]);
		}
	});
	$("textarea").each(function() {
		str_name = $(this).attr('id');
		if (!isSpace(str_name) && str_name.indexOf("txt_") == 0) {
			str_key = str_name.substring(4);
			if (str_key in rstData)
				$('#' + str_name).html(rstData[str_key]);
		}
	});
}

//ctrlId点击此控件弹出全屏, pid为a标签id
function OpenPopup(ctrlId, pid) {
	$("#" + ctrlId).focus(function() {
		$("#a_show" + pid).click();
	});
}
//ctrlId显示中文的控件, ctrlHidId记录code的隐藏域, pid为a标签id
function ClosePopup(ctrlId, ctrlHidId, pid, icd_code, icd_name) {
	$("#" + ctrlHidId).val(icd_code);
	$("#" + ctrlId).val(icd_name);
	$("#a_close" + pid).click();
}
//ctrlId显示中文的控件, ctrlHidId记录code的隐藏域, pid为a标签id,divId
function LoadPopupData(pJson, ctrlId, ctrlHidId, pid, divId) {
	var dataJson = {
		"actName": "Doctor",
		"actTag": "Get_ICD"
	};
	if (!isSpace(pJson)) {
		for (var key in pJson) {
			dataJson[key] = pJson[key];
		}
	}
	GetPageData('', dataJson, function(rstData) {
		if (rstData.total > 0) {
			var str_cells = "";
			for (var i = 0; i < rstData.total; i++) {
				str_cells += "<div class=\"weui-cells\">";
				str_cells += "<a class=\"weui-cell weui-cell_access\" href=\"javascript:ClosePopup('" + ctrlId +
					"','" + ctrlHidId + "','" + pid + "','" + rstData.rows[i].value + "','" + rstData.rows[i]
					.content + "')\">";
				str_cells += "<div class=\"weui-cell__bd\">";
				str_cells += "<p>" + rstData.rows[i].content + "</p>";
				str_cells += "</div>";
				str_cells += "<div class=\"weui-cell__ft\">";
				str_cells += "</div>";
				str_cells += "</a>";
				str_cells += "</div>";
			}
			$("#" + divId).html(str_cells);
		} else {
			$("#" + divId).html("无查询结果");
		}
	});
}
